<template>
  <!--会签管理-单据申请-材料结算弹窗-->
  <j-modal :title="title" :width="width" :visible="visible" switchFullscreen @ok="handleOk"
    :okButtonProps="{ class:{'jee-hidden': disableSubmit} }" @cancel="handleCancel" okText="提交审核" cancelText="取消">
    <wt-cailiao-form ref="realForm" @ok="submitCallback" @error="handleCancel"
      :disabled="disableSubmit"></wt-cailiao-form>
    <template #footer>
      <a-button key="back" @click="handleCancel">取消</a-button>
      <a-button key="save" @click="handleSave">保存</a-button>
      <a-button key="submit" type="primary" @click="handleOk">提交审核</a-button>
    </template>
  </j-modal>
</template>

<script>
  import WtCailiaoForm from './WtCailiaoForm'
  export default {
    name: 'WtShenpiModal',
    components: {
      WtCailiaoForm
    },
    data() {
      return {
        title: '',
        width: 1000,
        visible: false,
        disableSubmit: false
      }
    },
    methods: {
      add(record) {
        this.visible = true
        this.$nextTick(() => {
          this.$refs.realForm.add(record);
        })
      },
      edit(record) {
        this.visible = true
        this.$nextTick(() => {
          this.$refs.realForm.edit(record);
        })
      },
      close() {
        this.$emit('close');
        this.visible = false;
      },
      handleOk() {
        this.$refs.realForm.submitForm('1');
      },
      submitCallback() {
        this.$emit('ok');
        this.visible = false;
      },
      handleCancel() {
        this.close()
      },
      handleSave(){
        this.$refs.realForm.submitForm('0')
      }
    }
  }
</script>